package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.ShenHeTongJiBean;

import java.util.List;

/**
 * @author fei
 * @date 2024/5/15
 * @description
 */
public class ShenHeTongJiAdapter extends BaseAdapter {

    private Context mContext;
    private List<ShenHeTongJiBean> list;

    public ShenHeTongJiAdapter(List<ShenHeTongJiBean> data, Context context) {
        this.mContext = context;
        list=data;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;


        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_shenhe_tongji, parent, false);
            viewHolder = new ViewHolder();


            viewHolder.ll_body = (LinearLayout) convertView.findViewById(R.id.ll_body);
            viewHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            viewHolder.tv_text = (TextView) convertView.findViewById(R.id.tv_text);

            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        // 这里只是模拟，实际开发可能需要加载网络图片，可以使用ImageLoader这样的图片加载框架来异步加载图片
//        imageLoader.displayImage("drawable://" + mThumbIds[position], viewHolder.itemImg);


        ShenHeTongJiBean shenHeTongJiBean = list.get(position);
        viewHolder.tv_name.setText(shenHeTongJiBean.getContracttypename());
        viewHolder.tv_text.setText(shenHeTongJiBean.getCounts());

//        int num = position % 4;
//        switch (num){
//            case 0:
//                viewHolder.ll_body.setBackground(mContext.getResources().getDrawable(R.drawable.shape_orange_horn_disable));
//                break;
//            case 1:
                viewHolder.ll_body.setBackground(mContext.getResources().getDrawable(R.drawable.input_blue_line));
//                break;
//            case 2:
//                viewHolder.ll_body.setBackground(mContext.getResources().getDrawable(R.drawable.shape_gary_horn_disable));
//                break;
//            case 3:
//                viewHolder.ll_body.setBackground(mContext.getResources().getDrawable(R.drawable.shape_red_horn_disable));
//                break;
//        }

//        Glide.with(mContext).load("http://cn.bing.com/az/hprichbg/rb/Dongdaemun_ZH-CN10736487148_1920x1080.jpg").into(viewHolder.iv_icon);
//        GlideEngine.createGlideEngine().loadImage(mContext, askFourBtnBean.getProductImage(), viewHolder.iv_icon);
//        viewHolder.iv_icon.setImageResource(askFourBtnBean.getBigIcon());



        return convertView;
    }
    class ViewHolder {
        LinearLayout ll_body;
        TextView tv_name;
        TextView tv_text;
    }
}
